<template>
  <div>
    <!-- 登录主内容区域 -->
    <div class="login-container">
      <!-- 登录/注册表单 -->
      <div class="login-form">
        <!-- 标签页 -->
        <div class="tabs">
          <div
            class="tab"
            :class="{ active: activeTab === 'login' }"
            @click="activeTab = 'login'">
            登录
          </div>
          <div
            class="tab"
            :class="{ active: activeTab === 'register' }"
            @click="activeTab = 'register'">
            注册
          </div>
        </div>

        <!-- 登录表单 -->
        <div class="form-content">
          <!-- 登录表单 -->
          <div v-if="activeTab === 'login'">
            <MyLogin />
          </div>

          <!-- 注册表单 -->
          <div v-if="activeTab === 'register'">
            <MyRegister></MyRegister>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
const activeTab = ref("login"); // 默认显示登录表单
const route = useRoute();
// 页面加载时，根据路由参数切换标签页
onMounted(() => {
  // 如果路由参数中有name，且值为'register'，则切换到注册表单
  if (route.query.name === "register") {
    activeTab.value = "register";
  }
});
</script>

<style lang="scss" scoped>
.login-container {
  min-height: 655px;
  background-color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.login-form {
  width: 400px;
  background-color: #ffffff;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  padding: 30px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 30px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  cursor: pointer;
  font-size: 18px;
  color: #666;
  transition: all 0.3s;
}

.tab.active {
  color: #0066cc;
  border-bottom: 2px solid #0066cc;
}

.form-content {
  padding: 10px 0;
  min-height: 350px;
}

.form-group {
  margin-bottom: 20px;
}

/* 右侧功能按钮 */
.right-buttons {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.side-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.button-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}

.button-icon:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.button-icon img {
  width: 20px;
  height: 20px;
}

.button-text {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}
</style>
